package top.truehaku.generator.code.domain.model.column;



import lombok.Getter;
import lombok.Setter;
import top.truehaku.generator.common.domain.ValueObject;
import top.truehaku.generator.common.util.StringUtils;

public class ColumnId implements ValueObject<ColumnId> {

    @Getter@Setter
    private String tableScheme;

    @Getter@Setter
    private String tableName;

    @Getter@Setter
    private String columnName;

    public ColumnId(final String tableScheme, final String tableName,final String columnName) {
        if (StringUtils.isEmpty(tableScheme)){
            throw new IllegalArgumentException("数据库库名不能为空");
        }
        if (StringUtils.isEmpty(tableName)){
            throw new IllegalArgumentException("表名不能为空");
        }
        if (StringUtils.isEmpty(columnName)){
            throw new IllegalArgumentException("字段不能为空");
        }
        this.tableScheme = tableScheme;
        this.tableName = tableName;
        this.columnName = columnName;
    }

    @Override
    public boolean sameValueAs(ColumnId other) {
        return  other!=null
                &&this.tableScheme.equals(other.tableScheme)
                &&this.tableName.equals(other.tableName)
                &&this.columnName.equals(other.columnName)
                ;
    }

}
